#pragma once

// Simple camera class that lets the viewer explore the 3D scene.
//   -It keeps track of the camera coordinate system relative to the world space
//    so that the view matrix can be obtained.  
//   -It keeps track of the viewing frustum of the camera so that the projection
//    matrix can be obtained.

#include "Frustum.h"

namespace mscene
{
	class Camera
	{
	public:
		Camera();
		~Camera();

		XMFLOAT3 position() const;
		XMFLOAT3 look() const;
		XMFLOAT3 right() const;
		XMFLOAT3 up() const;

		XMFLOAT4X4 view()const;
		XMFLOAT4X4 proj()const;

		XMMATRIX getViewProjAligned() const;

		void setLens(float fovY, float aspectRatio, float zn, float zf);

		void strafe(float d);
		void moveVertically(float d);
		void walk(float d);

		void pitch(float angle);
		void rotateY(float angle);

		void setPosition(XMFLOAT3 pos);
		void setLook(XMFLOAT3 look);
		void setUp(XMFLOAT3 up);
		void setRight(XMFLOAT3 right);

		void resetOrientation();

		void rebuildView();
		//void rebuildViewOld();

		mmath::FrustumPersp Frustum_;

	private:
		XMFLOAT3 mPosition;
		XMFLOAT3 mRight;
		XMFLOAT3 mUp;
		XMFLOAT3 mLook;

		XMFLOAT4X4 mView;
		XMFLOAT4X4 mProj;

		float mFov, mAspectRatio, mNearDist, mFarDist;
	};
}
